package com.ruiyi.subway.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel
public class RestResponse<T> {
	@ApiModelProperty(value="请求是否成功")
	private boolean success;
	@ApiModelProperty(value="请求失败返回的消息")
	private String message;
	@ApiModelProperty(value="请求返回的数据内容")
	private T content;
	
	public static <T> RestResponse<T> success(T content){
		RestResponse<T> resp = new RestResponse<T>();
		resp.setSuccess(true);
		resp.setContent(content);
		return resp;
	}
	
	public static RestResponse<String> failed(String message){
		RestResponse<String> resp = new RestResponse<String>();
		resp.setSuccess(false);
		resp.setMessage(message);
		return resp;
	}
	
	public static RestResponse<String> success() {
		RestResponse<String> resp = new RestResponse<String>();
		resp.setSuccess(true);
		return resp;
	}
	
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public T getContent() {
		return content;
	}
	public void setContent(T content) {
		this.content = content;
	}
}
